home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / language / cyrillic.el.z / cyrillic.el
Encoding:
Text File  |  1998-05-21  |  11.7 KB  |  296 lines

  1. ;;; cyrillic.el --- Support for languages which use Cyrillic characters
  2.  
  3. ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
  4. ;; Licensed to the Free Software Foundation.
  5. ;; Copyright (C) 1997 MORIOKA Tomohiko
  6.  
  7. ;; Keywords: multilingual, Cyrillic
  8.  
  9. ;; This file is part of XEmacs.
  10.  
  11. ;; XEmacs is free software; you can redistribute it and/or modify it
  12. ;; under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 2, or (at your option)
  14. ;; any later version.
  15.  
  16. ;; XEmacs is distributed in the hope that it will be useful, but
  17. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19. ;; General Public License for more details.
  20.  
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with XEmacs; see the file COPYING.  If not, write to the Free
  23. ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  24. ;; 02111-1307, USA.
  25.  
  26. ;;; Commentary:
  27.  
  28. ;; The character set ISO8859-5 is supported.  KOI-8 and ALTERNATIVNYJ
  29. ;; are converted to ISO8859-5 internally.
  30.  
  31. ;;; Code:
  32.  
  33. ;; For syntax of Cyrillic
  34. (modify-syntax-entry 'cyrillic-iso8859-5 "w")
  35. (modify-syntax-entry ?,L-(B ".")
  36. (modify-syntax-entry ?,Lp(B ".")
  37. (modify-syntax-entry ?,L}(B ".")
  38.  
  39. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  40. ;;; CYRILLIC
  41. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  42.  
  43. ;; (define-prefix-command 'describe-cyrillic-environment-map)
  44. ;; (define-key-after describe-language-environment-map [Cyrillic]
  45. ;;   '("Cyrillic" . describe-cyrillic-environment-map)
  46. ;;   t)
  47.  
  48. ;; (define-prefix-command 'setup-cyrillic-environment-map)
  49. ;; (define-key-after setup-language-environment-map [Cyrillic]
  50. ;;   '("Cyrillic" . setup-cyrillic-environment-map)
  51. ;;   t)
  52.  
  53. ;; (define-language-environment 'cyrillic
  54. ;;   "Cyrillic"
  55. ;;   (lambda ()
  56. ;;     (set-coding-category-system 'iso-8-designate 'iso-8859-5)
  57. ;;     (set-coding-priority-list '(iso-8-designate iso-8-1))
  58. ;;     (set-default-buffer-file-coding-system 'iso-8859-5)
  59. ;;     (setq terminal-coding-system 'iso-8859-5)
  60. ;;     (setq keyboard-coding-system 'iso-8859-5)
  61. ;;     ;; (setq-default quail-current-package
  62. ;;     ;;               (assoc "yawerty" quail-package-alist))
  63. ;;     ))
  64.  
  65. ;; ISO-8859-5 staff
  66.  
  67. ;; (make-coding-system
  68. ;;  'cyrillic-iso-8bit 2 ?5
  69. ;;  "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)"
  70. ;;  '((ascii t) (cyrillic-iso8859-5 t) nil nil
  71. ;;    nil ascii-eol ascii-cntl nil nil nil nil))
  72.  
  73. ;; (define-coding-system-alias 'iso-8859-5 'cyrillic-iso-8bit)
  74.  
  75. (make-coding-system
  76.  'iso-8859-5 'iso2022
  77.  "MIME ISO-8859-5"
  78.  '(charset-g0 ascii
  79.    charset-g1 cyrillic-iso8859-5
  80.    charset-g2 t
  81.    charset-g3 t
  82.    mnemonic "ISO8/Cyr"
  83.    ))
  84.  
  85. (set-language-info-alist
  86.  "Cyrillic-ISO" '((setup-function . (setup-cyrillic-iso-environment
  87.                      . setup-cyrillic-environment-map))
  88.           (charset . (cyrillic-iso8859-5))
  89.           (coding-system . (iso-8859-5))
  90.           (sample-text . "Russian (,L@caaZXY(B)    ,L7T`PRabRcYbU(B!")
  91.           (documentation . ("Support for Cyrillic ISO-8859-5."
  92.                     . describe-cyrillic-environment-map))))
  93.  
  94. ;; KOI-8 staff
  95.  
  96. (define-ccl-program ccl-decode-koi8
  97.   '(((read r0)
  98.      (loop
  99.      (write-read-repeat
  100.       r0
  101.           [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  102.        16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  103.        32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  104.        48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
  105.        64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
  106.        80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
  107.        96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
  108.        112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
  109.        128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
  110.        144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
  111.         32  32  32 ?,Lq(B   32  32  32  32  32  32  32  32  32  32  32  32
  112.         32  32  32 ?,L!(B   32  32  32  32  32  32  32  32  32  32  32  32
  113.        ?,Ln(B  ?,LP(B  ?,LQ(B  ?,Lf(B  ?,LT(B  ?,LU(B  ?,Ld(B  ?,LS(B  ?,Le(B  ?,LX(B  ?,LY(B  ?,LZ(B  ?,L[(B  ?,L\(B  ?,L](B  ?,L^(B 
  114.        ?,L_(B  ?,Lo(B  ?,L`(B  ?,La(B  ?,Lb(B  ?,Lc(B  ?,LV(B  ?,LR(B  ?,Ll(B  ?,Lk(B  ?,LW(B  ?,Lh(B  ?,Lm(B  ?,Li(B  ?,Lg(B  ?,Lj(B 
  115.        ?,LN(B  ?,L0(B  ?,L1(B  ?,LF(B  ?,L4(B  ?,L5(B  ?,LD(B  ?,L3(B  ?,LE(B  ?,L8(B  ?,L9(B  ?,L:(B  ?,L;(B  ?,L<(B  ?,L=(B  ?,L>(B 
  116.        ?,L?(B  ?,LO(B  ?,L@(B  ?,LA(B  ?,LB(B  ?,LC(B  ?,L6(B  ?,L2(B  ?,LL(B  ?,LK(B  ?,L7(B  ?,LH(B  ?,LM(B  ?,LI(B  ?,LG(B  ?,LJ(B ]))))
  117.   "CCL program to decode KOI8.")
  118.  
  119. (define-ccl-program ccl-encode-koi8
  120.   '(((read r0)
  121.      (loop
  122.      (if (r0 != 140)        ; lc-crl == 140
  123.          (write-read-repeat r0)
  124.        ((read r0)
  125.         (r0 -= 160)
  126.         (write-read-repeat
  127.          r0
  128.          [ 32 179  32  32  32  32  32  32  32  32  32  32  32  32  32  32
  129.           225 226 247 231 228 229 246 250 233 234 235 236 237 238 239 240
  130.           242 243 244 245 230 232 227 254 251 253 255 249 248 252 224 241
  131.           193 194 215 199 196 197 214 218 201 202 203 204 205 206 207 208
  132.           210 211 212 213 198 200 195 222 219 221 223 217 216 220 192 209
  133.            32 163  32  32  32  32  32  32  32  32  32  32  32  32  32  32])
  134.         )))))
  135.   "CCL program to encode KOI8.")
  136.          
  137. ;; (make-coding-system
  138. ;;  'cyrillic-koi8 4
  139. ;;  ;; We used to use ?K.  It is true that ?K is more strictly correct,
  140. ;;  ;; but it is also used for Korean.
  141. ;;  ;; So people who use koi8 for languages other than Russian
  142. ;;  ;; will have to forgive us.
  143. ;;  ?R "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)"
  144. ;;  (cons ccl-decode-koi8 ccl-encode-koi8))
  145.  
  146. ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
  147. ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
  148.  
  149. ;; (make-coding-system
  150. ;;  'koi8-r 'ccl
  151. ;;  "Coding-system used for KOI8-R."
  152. ;;  `(decode ,ccl-decode-koi8
  153. ;;    encode ,ccl-encode-koi8
  154. ;;    mnemonic "KOI8"))
  155.  
  156. ;;(define-coding-system-alias 'koi8-r 'koi8)
  157.  
  158. (define-ccl-program ccl-encode-koi8-font
  159.   '(((r1 -= 160)
  160.      (r1 = r1
  161.       [ 32 179  32  32  32  32  32  32  32  32  32  32  32  32  32  32
  162.        225 226 247 231 228 229 246 250 233 234 235 236 237 238 239 240
  163.        242 243 244 245 230 232 227 254 251 253 255 249 248 252 224 241
  164.        193 194 215 199 196 197 214 218 201 202 203 204 205 206 207 208
  165.        210 211 212 213 198 200 195 222 219 221 223 217 216 220 192 209
  166.         32 163  32  32  32  32  32  32  32  32  32  32  32  32  32  32])
  167.      ))
  168.   "CCL program to encode Cyrillic chars to KOI font.")
  169.  
  170. ;; (setq font-ccl-encoder-alist
  171. ;;       (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
  172.  
  173. (set-language-info-alist
  174.  "Cyrillic-KOI8" '((setup-function . (setup-cyrillic-koi8-environment
  175.                       . setup-cyrillic-environment-map))
  176.            (charset . (cyrillic-iso8859-5))
  177.            (coding-system . (koi8-r))
  178.            (sample-text . "Russian (,L@caaZXY(B)    ,L7T`PRabRcYbU(B!")
  179.            (documentation . ("Support for Cyrillic KOI-8."
  180.                      . describe-cyrillic-environment-map))))
  181.  
  182. ;;; ALTERNATIVNYJ staff
  183.  
  184. (define-ccl-program ccl-decode-alternativnyj
  185.   '(((read r0)
  186.      (loop
  187.      (write-read-repeat
  188.       r0
  189.           [  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
  190.         16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31
  191.         32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47
  192.         48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63
  193.         64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79
  194.         80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95
  195.         96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111
  196.        112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
  197.         ?,L0(B  ?,L1(B  ?,L2(B  ?,L3(B  ?,L4(B  ?,L5(B  ?,L6(B  ?,L7(B  ?,L8(B  ?,L9(B  ?,L:(B  ?,L;(B  ?,L<(B  ?,L=(B  ?,L>(B  ?,L?(B
  198.         ?,L@(B  ?,LA(B  ?,LB(B  ?,LC(B  ?,LD(B  ?,LE(B  ?,LF(B  ?,LG(B  ?,LH(B  ?,LI(B  ?,LJ(B  ?,LK(B  ?,LL(B  ?,LM(B  ?,LN(B  ?,LO(B
  199.         ?,LP(B  ?,LQ(B  ?,LR(B  ?,LS(B  ?,LT(B  ?,LU(B  ?,LV(B  ?,LW(B  ?,LX(B  ?,LY(B  ?,LZ(B  ?,L[(B  ?,L\(B  ?,L](B  ?,L^(B  ?,L_(B
  200.         32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32
  201.         32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32
  202.         32  32  32  32  32  32  32  32  32  32  32  32  32  32  32  32
  203.         ?,L`(B  ?,La(B  ?,Lb(B  ?,Lc(B  ?,Ld(B  ?,Le(B  ?,Lf(B  ?,Lg(B  ?,Lh(B  ?,Li(B  ?,Lj(B  ?,Lk(B  ?,Ll(B  ?,Lm(B  ?,Ln(B  ?,Lo(B
  204.         ?,L!(B  ?,Lq(B   32  32  32  32  32  32  32  32  32  32  32  32  32 ?,Lp(B]))))
  205.   "CCL program to decode Alternativnyj.")
  206.  
  207. (define-ccl-program ccl-encode-alternativnyj
  208.   '(((read r0)
  209.      (loop
  210.      (if (r0 != 140)        ; lc-crl == 140
  211.          (write-read-repeat r0)
  212.        ((read r0)
  213.         (r0 -= 160)
  214.         (write-read-repeat
  215.          r0
  216.          [ 32 240  32  32  32  32  32  32  32  32  32  32  32  32  32  32
  217.           128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
  218.           144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
  219.           160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
  220.           224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
  221.           255 241  32  32  32  32  32  32  32  32  32  32  32  32  32  32])
  222.         )))))
  223.   "CCL program to encode Alternativnyj.")
  224.  
  225. ;; (make-coding-system
  226. ;;  'alternativnyj 4
  227. ;;  ?A "Coding-system used for Alternativnyj"
  228. ;;  (cons ccl-decode-alternativnyj ccl-encode-alternativnyj))
  229.  
  230. (make-coding-system
  231.  'alternativnyj 'ccl
  232.  "Coding-system used for Alternativnyj"
  233.  `(decode ,ccl-decode-alternativnyj
  234.    encode ,ccl-encode-alternativnyj
  235.    mnemonic "Cy.Alt"))
  236.  
  237. (define-ccl-program ccl-encode-alternativnyj-font
  238.   '(((r1 -= 160)
  239.      (r1 = r1
  240.       [ 32 240  32  32  32  32  32  32  32  32  32  32  32  32  32  32
  241.        128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
  242.        144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
  243.        160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
  244.        224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
  245.        255 241  32  32  32  32  32  32  32  32  32  32  32  32  32  32])
  246.      ))
  247.   "CCL program to encode Cyrillic chars to Alternativnyj font.")
  248.  
  249. ;; (setq font-ccl-encoder-alist
  250. ;;       (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
  251. ;;             font-ccl-encoder-alist))
  252.  
  253. (set-language-info-alist
  254.  "Cyrillic-ALT" '((setup-function . (setup-cyrillic-alternativnyj-environment
  255.                      . setup-cyrillic-environment-map))
  256.           (charset . (cyrillic-iso8859-5))
  257.           (coding-system . (alternativnyj))
  258.           (sample-text . "Russian (,L@caaZXY(B)    ,L7T`PRabRcYbU(B!")
  259.           (documentation . ("Support for Cyrillic ALTERNATIVNYJ."
  260.                     . describe-cyrillic-environment-map))))
  261.  
  262. ;;; GENERAL
  263.  
  264. ;; (defun setup-cyrillic-environment ()
  265. ;;   "Setup multilingual environment for Cyrillic users."
  266. ;;   (interactive)
  267. ;;   (setq primary-language "Cyrillic")
  268. ;; 
  269. ;;   (setq coding-category-iso-8-1 'iso-8859-5)
  270. ;; 
  271. ;;   (set-coding-priority
  272. ;;    '(coding-category-iso-7
  273. ;;      coding-category-iso-8-1))
  274. ;; 
  275. ;;   (setq-default buffer-file-coding-system 'iso-8859-5)
  276. ;;   (set-terminal-coding-system 'iso-8859-5)
  277. ;;   (set-keyboard-coding-system 'iso-8859-5)
  278. ;; 
  279. ;;   (setq default-input-method '("Cyrillic" . "quail-yawerty"))
  280. ;;   )
  281.  
  282. ;; (defun describe-cyrillic-support ()
  283. ;;   "Describe how Emacs support Cyrillic."
  284. ;;   (interactive)
  285. ;;   (describe-language-support-internal "Cyrillic"))
  286.  
  287. ;; (set-language-info-alist
  288. ;;  "Cyrillic" '((setup-function . setup-cyrillic-environment)
  289. ;;               (describe-function . describe-cyrillic-support)
  290. ;;               (charset . (cyrillic-iso8859-5))
  291. ;;               (coding-system . (iso-8859-5 koi8-r alternativnyj))
  292. ;;               (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
  293. ;;               (documentation . nil)))
  294.  
  295. ;;; cyrillic.el ends here
  296.